package org.jeecg.modules.travel.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.wxhtml.service.WxHtmlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name="测试微信")
@RestController
@RequestMapping("/travel/text")
@Slf4j
public class TextController {

    @Autowired
    private WxHtmlService wxHtmlService;

    @Operation(summary="测试微信-token")
    @GetMapping("/getAccessToken")
    public Result<?> getAccessToken(@RequestParam(name = "code") String code) {
        return Result.ok(wxHtmlService.getAccessToken(code));
    }

    @Operation(summary="测试微信-token")
    @GetMapping("/refreshToken")
    public Result<?> refreshToken(@RequestParam(name = "refreshToken") String refreshToken) {
        return Result.ok(wxHtmlService.refreshToken(refreshToken));
    }

    @Operation(summary="测试微信-token")
    @GetMapping("/snsApiUserinfo")
    public Result<?> snsApiUserinfo(@RequestParam(name = "accessToken") String accessToken,
                                    @RequestParam(name = "openid") String openid) {
        return Result.ok(wxHtmlService.snsApiUserinfo(accessToken,openid));
    }

    @Operation(summary="测试微信-token")
    @GetMapping("/auth")
    public Result<?> auth(@RequestParam(name = "accessToken") String accessToken,
                          @RequestParam(name = "openid") String openid) {
        return Result.ok(wxHtmlService.auth(accessToken,openid));
    }

}
